#include "xeditdialog.h"
#include "ui_xeditdialog.h"
#include <QFile>
#include <QTextStream>


XEditDialog::XEditDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::XEditDialog)
{
    ui->setupUi(this);

	QFile file("./test.ini");
	if (!file.open(QIODevice::ReadWrite))
		return;
	QTextStream out(&file);
	while (!file.atEnd())
	{
		ui->textEdit->setText(out.readAll());
	}
}

XEditDialog::~XEditDialog()
{
    delete ui;
}

void XEditDialog::on_btn_save_clicked()
{
	QFile file("./test.ini");
	if (!file.open(QIODevice::WriteOnly))
		return;
	QTextStream in(&file);
	
	//ui->textEdit->setText();

	in << ui->textEdit->toPlainText();
	in.flush();

	file.close();
	emit accept();
	
}

void XEditDialog::on_btn_cancel_clicked()
{
	emit reject();
}
